<template>
	<view class="container">
		<u-navbar title="我的特权" :border-bottom="false" title-color="#E4B993" back-icon-color="#E4B993"
			:background="{backgroundColor:'#272325'}"></u-navbar>
		<view class="container_main">
			<view class="container_main_tp">
				<view class="u-font-weight">
					我的套餐：{{data.mySetmeal.name}}
				</view>
				<view class="u-m-t-16" v-if="data.mySetmeal.deadline == 0">
					有效时间：无限期
				</view>
				<view class="u-m-t-16" v-else>
					有效时间：{{$u.timeFormat(data.mySetmeal.deadline)}}
				</view>
			</view>
			<view class="container_main_resource">
				<view class="container_main_resource_tit">
					我的资源
				</view>
				<view class="container_main_resource_box">
					<view class="u-flex u-row-between u-m-b-44">
						<view>职位并发（{{data.mySetmeal.jobs_meanwhile}}）</view>
						<view class="container_main_resource_box_btn" @click="handleToJob">
							发职位
						</view>
					</view>
					<view class="u-flex u-row-between u-m-b-44">
						<view>简历点（{{data.mySetmeal.download_resume_point}}）</view>
						<view class="container_main_resource_box_btn" @click="handleToResume">
							搜简历
						</view>
					</view>
					<view class="u-flex u-row-between">
						<view>职聊次数（{{data.mySetmeal.im_total}}）</view>
						<view class="container_main_resource_box_btn" @click="handleToChat">
							去沟通
						</view>
					</view>
				</view>
			</view>
			<view class="container_main_privilege">
				<view class="container_main_privilege_item container_main_privilege_tip">
					我的特权
				</view>
				<view class="container_main_privilege_item">
					<view>
						免费刷新职位次数
					</view>
					<view>
						{{data.mySetmeal.refresh_jobs_free_perday}}次/天
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						下载简历数上限
					</view>
					<view>
						{{data.mySetmeal.download_resume_max_perday}}份/天
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						职聊次数上限
					</view>
					<view>
						{{data.mySetmeal.im_max_perday}}次/天
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						增值服务专享折扣
					</view>
					<view v-if="data.mySetmeal.service_added_discount > 0">
						{{data.mySetmeal.service_added_discount}}折
					</view>
					<view v-else>
						无折扣
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						收到的简历免费看
					</view>
					<view>
						{{ data.mySetmeal.show_apply_contact == 1 ? "支持" : "暂不支持" }}
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						微海报
					</view>
					<view>
						{{ data.mySetmeal.enable_poster == 1 ? "支持" : "暂不支持" }}
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						会员专属标识
					</view>
					<view>
						会员标识
					</view>
				</view>
				<view class="container_main_privilege_item">
					<view>
						专属金牌客服
					</view>
					<view>
						客服快速响应
					</view>
				</view>
				<view class="container_main_privilege_btn" @click="uploadPackage">
					升级套餐
				</view>
			</view>
		</view>
		<u-modal v-model="data.isJobNum" title="系统提示"
			:content="`您当前是${data.setmeal_name}，当前可发布职位数为0，建议您立即升级套餐或将暂时不招聘的职位设为关闭`" confirmText="升级套餐" showCancelButton
			@confirm="uploadPackage"></u-modal>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		reactive
	} from "vue";
	const data = reactive({
		mySetmeal: {},
		isJobNum: false,
		setmeal_name: ''
	})
	onLoad(() => {
		getMysetmeal()
	})
	// 去升级套餐
	const uploadPackage = () => {
		uni.$u.route('/pages/pagesPersonal/toolMall/package')
	}
	// 去发布职位
	const handleToJob = async () => {
		let res = await uni.$u.api.checkJobaddNumber()
		if (res.enable_addjob_num <= 0) {
			data.setmeal_name = res.setmeal_name
			data.isJobNum = true
			return
		}
		uni.$u.route('/pages/pagesPersonal/job/jobEdit/jobEdit')
	}
	// 去首页
	const handleToChat = () => {
		uni.$u.route({
			type: 'tab',
			url: '/pages/home/home'
		})
	}
	// 去搜索页面
	const handleToResume = () => {
		uni.$u.route('/pages/pagesHome/search/index')
	}
	// 获取企业特权信息
	const getMysetmeal = async () => {
		let {
			info
		} = await uni.$u.api.getMysetmeal()
		data.mySetmeal = info
	}
</script>

<style>
	page {
		background-color: #272325;
	}
</style>
<style lang="scss" scoped>
	.container {
		&_main {
			padding: 70rpx 32rpx;

			&_tp {
				background-image: url('/pages/pagesPersonal/static/privilege.jpg');
				background-size: 100% 100%;
				height: 264rpx;
				text-align: center;
				padding-top: 40rpx;
				color: #fff;
				font-size: 26rpx;
				color: #BA6316;
			}

			&_resource {
				border: 2rpx solid #FFA657;

				&_tit {
					text-align: center;
					font-weight: bold;
					color: #FFA85C;
					font-size: 32rpx;
					height: 128rpx;
					line-height: 128rpx;
					border-bottom: 2rpx solid #FFA657;
				}

				&_box {
					padding: 50rpx 26rpx;
					font-size: 28rpx;
					color: #F7BC87;

					&_btn {
						border: 2rpx solid #E2A36B;
						padding: 10rpx 30rpx;
						border-radius: 30rpx;
					}
				}
			}

			&_privilege {
				border: 2rpx solid #FFA657;
				border-top: none;
				padding: 56rpx 36rpx;
				font-size: 28rpx;

				&_item {
					border: 2rpx solid #FFA657;
					margin-bottom: 22rpx;
					display: flex;
					justify-content: space-between;
					color: #F7BC87;
					padding: 18rpx;
				}

				&_tip {
					background: linear-gradient(180deg, rgba(242, 183, 130, 1) 0%, rgba(240, 216, 194, 1) 100%);
					color: #B6631A;
					justify-content: center;
					font-size: 32rpx;
					font-weight: bold;
				}

				&_btn {
					background: linear-gradient(-89.08deg, rgba(242, 183, 130, 1) 0.76%, rgba(240, 216, 194, 1) 99.01%);
					color: #B6631A;
					width: 354rpx;
					height: 88rpx;
					line-height: 88rpx;
					text-align: center;
					margin: 0 auto;
					margin-top: 36rpx;
					border-radius: 46rpx;
				}
			}
		}
	}
</style>